<div class="popform">
    <div class="popup-filelist">
        <ul class="fl">
            <li class="top">
                <?php $progressDoc1 = $this->progressDoc($this->switchDetail['id'], 'ritningar'); ?>
                <form method="post" action="/planning/switch/uploadprogressfile/<?= $this->switchDetail['id'] ?>/ritningar" enctype="multipart/form-data">
                    <label>Ritningar:</label>
                    <div class="inputbg"><input type="checkbox" name="ritningar" <?php echo ($this->switchDetail['ritningar']) ? 'checked' : '' ?> onclick="toggleStatus('ritningar','<?= $this->switchDetail['ritningar'] ?>','<?= $this->switchDetail['id'] ?>')" <?=($progressDoc1['switch_progress_name'])?'Disabled':''?>></div>
                    <div class="clr"></div>

                    <label>File:</label>
                    <?php if ($progressDoc1['switch_progress_name']) { ?>
                        <a href="<?= $this->baseURI(); ?>planning/document/download/<?= $progressDoc1['file']; ?>"><?= $progressDoc1['name']; ?></a> |
                        <?php if ($this->userDetail->role == 'superadmin'){?>
                           <a href='javascript:void(0)' onclick="deleteFile('<?=$progressDoc1['id']?>','<?=$this->switchDetail['id']?>')">Delete</a>
                        <?php }?>
                    <?php } else { ?>
                        <div class="inputbg"><input type="file" name="doc"></div>
                        <div class="inputbg"><input type="submit" name="upload" value="Upload"></div>
                    <?php } ?>
                    <div class="clr"></div>
                </form>
            </li>
            <li class="top">
                <?php $progressDoc2 = $this->progressDoc($this->switchDetail['id'], 'skarvschema'); ?>
                <form method="post" action="/planning/switch/uploadprogressfile/<?= $this->switchDetail['id'] ?>/skarvschema" enctype="multipart/form-data">
                    <label>Skarvschema:</label>
                    <div class="inputbg"><input type="checkbox" name="skarvschema" <?php echo ($this->switchDetail['skarvschema']) ? 'checked' : '' ?> onclick="toggleStatus('skarvschema','<?= $this->switchDetail['skarvschema'] ?>','<?= $this->switchDetail['id'] ?>')" <?=($progressDoc2['switch_progress_name'])?'Disabled':''?>></div>
                    
                    <div class="clr"></div>
                    
                    <label>File:</label>
                    <?php if ($progressDoc2['switch_progress_name']) { ?>
                        <a href="<?= $this->baseURI(); ?>planning/document/download/<?= $progressDoc2['file']; ?>"><?= $progressDoc2['name']; ?></a>
                        <?php if ($this->userDetail->role == 'superadmin'){?>
                           <a href='javascript:void(0)' onclick="deleteFile('<?=$progressDoc2['id']?>','<?=$this->switchDetail['id']?>')">Delete</a>
                        <?php }?>
                    <?php } else { ?>
                        <div class="inputbg"><input type="file" name="doc"></div>
                        <div class="inputbg"><input type="submit" name="upload" value="Upload"></div>
                    <?php } ?>
                    <div class="clr"></div>
                </form>
            </li>
            <li class="top">
                <?php $progressDoc3 = $this->progressDoc($this->switchDetail['id'], 'mangdning'); ?>
                <form method="post" action="/planning/switch/uploadprogressfile/<?= $this->switchDetail['id'] ?>/mangdning" enctype="multipart/form-data">
                    <label>Mängdning :</label>
                    <div class="inputbg"><input type="checkbox" name="mangdning" <?php echo ($this->switchDetail['mangdning']) ? 'checked' : '' ?> onclick="toggleStatus('mangdning','<?= $this->switchDetail['mangdning'] ?>','<?= $this->switchDetail['id'] ?>')" <?=($progressDoc3['switch_progress_name'])?'Disabled':''?>></div>                    
                    <div class="clr"></div>
                    
                    <label>File:</label>
                    <?php if ($progressDoc3['switch_progress_name']) { ?>
                        <a href="<?= $this->baseURI(); ?>planning/document/download/<?= $progressDoc3['file']; ?>"><?= $progressDoc3['name']; ?></a>
                        <?php if ($this->userDetail->role == 'superadmin'){?>
                           <a href='javascript:void(0)' onclick="deleteFile('<?=$progressDoc3['id']?>','<?=$this->switchDetail['id']?>')">Delete</a>
                        <?php }?>
                    <?php } else { ?>
                        <div class="inputbg"><input type="file" name="doc"></div>
                        <div class="inputbg"><input type="submit" name="upload" value="Upload"></div>
                    <?php } ?>
                    <div class="clr"></div>
                </form>
            </li>
            <li class="top">
                <?php $progressDoc4 = $this->progressDoc($this->switchDetail['id'], 'budget'); ?>
                <form method="post" action="/planning/switch/uploadprogressfile/<?= $this->switchDetail['id'] ?>/budget" enctype="multipart/form-data">
                    <label>Budget:</label>
                    <div class="inputbg"><input type="checkbox" name="budget" <?php echo ($this->switchDetail['budget']) ? 'checked' : '' ?> onclick="toggleStatus('budget','<?= $this->switchDetail['budget'] ?>','<?= $this->switchDetail['id'] ?>')" <?=($progressDoc4['switch_progress_name'])?'Disabled':''?>></div>
                    
                    <div class="clr"></div>
                    
                    <label>File:</label>
                    <?php if ($progressDoc4['switch_progress_name']) { ?>
                        <a href="<?= $this->baseURI(); ?>planning/document/download/<?= $progressDoc4['file']; ?>"><?= $progressDoc4['name']; ?></a>
                        <?php if ($this->userDetail->role == 'superadmin'){?>
                           <a href='javascript:void(0)' onclick="deleteFile('<?=$progressDoc4['id']?>','<?=$this->switchDetail['id']?>')">Delete</a>
                        <?php }?>
                    <?php } else { ?>
                        <div class="inputbg"><input type="file" name="doc"></div>
                        <div class="inputbg"><input type="submit" name="upload" value="Upload"></div>
                    <?php } ?>
                    <div class="clr"></div>
                </form>
            </li>
            <li class="top">
                <?php $progressDoc5 = $this->progressDoc($this->switchDetail['id'], 'slutavstamning'); ?>
                <form method="post" action="/planning/switch/uploadprogressfile/<?= $this->switchDetail['id'] ?>/slutavstamning" enctype="multipart/form-data">
                    <label>Slutavstämning:</label>
                    <div class="inputbg"><input type="checkbox" name="slutavstamning" <?php echo ($this->switchDetail['slutavstamning']) ? 'checked' : '' ?> onclick="toggleStatus('slutavstamning','<?= $this->switchDetail['slutavstamning'] ?>','<?= $this->switchDetail['id'] ?>')" <?=($progressDoc5['switch_progress_name'])?'Disabled':''?>></div>
                    
                    <div class="clr"></div>
                    
                    <label>File:</label>
                    <?php if ($progressDoc5['switch_progress_name']) { ?>
                        <a href="<?= $this->baseURI(); ?>planning/document/download/<?= $progressDoc5['file']; ?>"><?= $progressDoc5['name']; ?></a>
                        <?php if ($this->userDetail->role == 'superadmin'){?>
                           <a href='javascript:void(0)' onclick="deleteFile('<?=$progressDoc5['id']?>','<?=$this->switchDetail['id']?>')">Delete</a>
                        <?php }?>
                    <?php } else { ?>
                        <div class="inputbg"><input type="file" name="doc"></div>
                        <div class="inputbg"><input type="submit" name="upload" value="Upload"></div>
                    <?php } ?>
                    <div class="clr"></div>
                </form>
            </li>
        </ul>
    </div>
</div>
<div class="clr"></div>
<div class="popform">
    <p><strong>Files:</strong></p>
    <div class="popup-filelist">
        <?php
        foreach ($this->files as $item) {
            $user = $this->getUserDetail($item['uploader_id']);
            ?>
            <ul>
                <li style="list-style: disc inside none"> 
                    <a href="<?= $this->baseURI(); ?>planning/document/download/<?= $item['file']; ?>"><?= $item['name']; ?></a>
                    by <?= $user['fname'] . ' ' . $user['lname']; ?> at <?= $item['date']; ?>
                </li>
            </ul>
        <?php } ?>
    </div>
</div>
<script>
    function toggleStatus(col,status,switchId){
        $.ajax({
            type: "POST",
            url: "<?= $this->baseURI(); ?>planning/switch/toggle/"+switchId, 
            data:({status:status,column:col}),
            success: function(msg){
                $("#myhouse-listing").load("<?= $this->baseURI(); ?>planning/switch/list/");
            }
        }); 
    }
</script>